package cn.itcast.controller;

import cn.itcast.entity.Result;
import cn.itcast.service.SmsService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/sms")
@Slf4j
public class SmsController {

    @Reference
    private SmsService smsService;

    @PostMapping("/sendLoginCode")
    public ResponseEntity<Result> sendLoginCode(String phone) {
        log.info("进入SmsController");

        Result result = null;
        try {
            result = smsService.sendLoginCode(phone);

        } catch (Exception e) {

            log.error("发送消息失败!");
        }
        return ResponseEntity.ok(result);
    }
}
